package com.ukao.steward.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.steward.R;
import com.ukao.steward.base.ListBaseAdapter;
import com.ukao.steward.base.SuperViewHolder;
import com.ukao.steward.bean.EnterFactoryBean;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.util.MyDateUtils;

import java.util.List;

/**
 * Created by ukaodev on 2017/8/24.
 */

public class EnterFactoryAdapter extends ListBaseAdapter<EnterFactoryBean.ListBean> {

private   int  enterType;


    public EnterFactoryAdapter(Context context, List<EnterFactoryBean.ListBean> mHomeBean,int  enterType ) {
        super(context, mHomeBean);
        this.enterType=enterType;

    }


    @Override
    public int getLayoutId() {
        return R.layout.adapter_enter_factory;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        EnterFactoryBean.ListBean item = mDataList.get(position);
        TextView storeName=holder.getView(R.id.storeName);
        TextView code=holder.getView(R.id.code);
        TextView logisticsWorkTime=holder.getView(R.id.logisticsWorkTime);
        TextView productCnt=holder.getView(R.id.productCnt);
        TextView count=holder.getView(R.id.count);
        TextView factoryName=holder.getView(R.id.factoryName);
        TextView factoryWorkTime=holder.getView(R.id.factoryWorkTime);
        LinearLayout factoryNamelayout=holder.getView(R.id.factoryName_layout);
        LinearLayout factoryWorkTimelayout=holder.getView(R.id.factoryWorkTime_layout);
        TextView codeMsg=holder.getView(R.id.code_msg);

        TextView transNo = holder.getView(R.id.transNo);
        LinearLayout transNolayout = holder.getView(R.id.transNo_layout);
        LinearLayout factoryTransNolayout = holder.getView(R.id.factoryTransNo_layout);
        TextView factoryTransNo = holder.getView(R.id.factoryTransNo);


        storeName.setText(CheckUtils.isEmptyString(item.getStoreName()));
        productCnt.setText(item.getProductCnt()+item.getAnnexCnt()+"");
        count.setText("(衣物"+item.getProductCnt()+"件,"+" 附件"+item.getAnnexCnt()+"件)");
        long   time= enterType==1||enterType==2?item.getLogisticsWorkTime():item.getTakeTime();
        code.setText( enterType==1||enterType==2?item.getCode():item.getOrderNo());
        logisticsWorkTime.setText(MyDateUtils.formatDataTime(time));
        switch(enterType) {
            case 1://未送厂

                factoryNamelayout.setVisibility(View.GONE);
                factoryWorkTimelayout.setVisibility(View.GONE);
                break;
            case 2:

                factoryNamelayout.setVisibility(View.VISIBLE);
                factoryWorkTimelayout.setVisibility(View.VISIBLE);
                factoryName.setText(CheckUtils.isEmptyString(item.getFactoryName()));
                factoryWorkTime.setText(MyDateUtils.formatDataTime(item.getFactoryWorkTime()));
                break;
            case  3:  /*未送厂*/
                transNo.setText(item.getTransNo());
                factoryTransNo.setText(item.getFactoryTransNo());
                transNolayout.setVisibility(View.VISIBLE);
                factoryTransNolayout.setVisibility(View.VISIBLE);
                codeMsg.setText("订单号");
                factoryNamelayout.setVisibility(View.GONE);
                factoryWorkTimelayout.setVisibility(View.GONE);
                break;

            case  4: /*已到厂*/
                codeMsg.setText("订单号");
                factoryNamelayout.setVisibility(View.VISIBLE);
                factoryWorkTimelayout.setVisibility(View.VISIBLE);
                factoryName.setText(CheckUtils.isEmptyString(item.getFactoryName()));
                factoryWorkTime.setText(MyDateUtils.formatDataTime(item.getCreateTime()));

                break;

        }
    }



}
